/*
 * BattleInterface.java
 *
 * Created on May 1, 2008, 12:32 AM
 */

package RPack;

import java.io.*;
import java.util.*;
import java.*;
/**
 *
 * @author  Administrator
 */

class Battle{
    public static String eName;
    public static int ehitpoints;
    public static int emanapoints;
    public static int ePower;
    public static int eAegis;
    public static int eSpeed;
    public static int eArcana;
    public static int battlenumber;
    public static int wins;
    public static int losses;
    public static int saves;
}

public class BattleInterface extends javax.swing.JFrame {
    
    /** Creates new form BattleInterface */
    public BattleInterface() {
        initComponents();
    }
    
     public void run(){
                new BattleInterface().setVisible(true);
                   
     }
     
public void beastiary(){
Random generator = new Random();
int v = generator.nextInt();
int e = v%10;
e = e+1;

switch (e) {
	case 1:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Athach";
				Battle.ehitpoints = 25;
				Battle.emanapoints = 0;
				Battle.ePower = 30;
				Battle.eAegis = 16;
				Battle.eSpeed = 12;
				Battle.eArcana = 7;
				break;
			case 2:
				Battle.eName = "Athach";
				Battle.ehitpoints = 50;
				Battle.emanapoints = 0;
				Battle.ePower = 60;
				Battle.eAegis = 32;
				Battle.eSpeed = 24;
				Battle.eArcana = 14;
				break;
			case 3:
				Battle.eName = "Athach";
				Battle.ehitpoints = 100;
				Battle.emanapoints = 0;
				Battle.ePower = 120;
				Battle.eAegis = 64;
				Battle.eSpeed = 48;
				Battle.eArcana = 28;
				break;
		}
	break;
	case 2:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Chimera";
				Battle.ehitpoints = 17;
				Battle.emanapoints = 14;
				Battle.ePower = 14;
				Battle.eAegis = 16;
				Battle.eSpeed = 12;
				Battle.eArcana = 16;
				break;
			case 2:
				Battle.eName = "Chimera";
				Battle.ehitpoints = 34;
				Battle.emanapoints =28;
				Battle.ePower = 28;
				Battle.eAegis = 32;
				Battle.eSpeed = 24;
				Battle.eArcana = 32;
				break;
			case 3:
				Battle.eName = "Chimera";
				Battle.ehitpoints = 68;
				Battle.emanapoints = 28;
				Battle.ePower = 56;
				Battle.eAegis = 64;
				Battle.eSpeed = 48;
				Battle.eArcana = 64;
				break;
		}
	break;
	case 3:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Dragon Turtle";
				Battle.ehitpoints = 23;
				Battle.emanapoints = 12;
				Battle.ePower = 16;
				Battle.eAegis = 30;
				Battle.eSpeed = 5;
				Battle.eArcana = 14;
				break;
			case 2:
				Battle.eName = "Dragon Turtle";
				Battle.ehitpoints = 46;
				Battle.emanapoints = 24;
				Battle.ePower = 32;
				Battle.eAegis = 60;
				Battle.eSpeed = 10;
				Battle.eArcana = 28;
				break;
			case 3:
				Battle.eName = "Dragon Turtle";
				Battle.ehitpoints = 62;
				Battle.emanapoints = 48;
				Battle.ePower = 64;
				Battle.eAegis = 120;
				Battle.eSpeed = 20;
				Battle.eArcana = 56;
				break;
		}
	break;
	case 4:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Genie";
				Battle.ehitpoints = 15;
				Battle.emanapoints = 30;
				Battle.ePower = 7;
				Battle.eAegis = 11;
				Battle.eSpeed = 18;
				Battle.eArcana = 30;
				break;
			case 2:
				Battle.eName = "Genie";
				Battle.ehitpoints = 34;
				Battle.emanapoints =28;
				Battle.ePower = 28;
				Battle.eAegis = 32;
				Battle.eSpeed = 24;
				Battle.eArcana = 32;
				break;
			case 3:
				Battle.eName = "Genie";
				Battle.ehitpoints = 68;
				Battle.emanapoints = 28;
				Battle.ePower = 56;
				Battle.eAegis = 64;
				Battle.eSpeed = 48;
				Battle.eArcana = 64;
				break;
		}
	break;
	case 5:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Gnoll";
				Battle.ehitpoints = 10;
				Battle.emanapoints = 0;
				Battle.ePower = 7;
				Battle.eAegis = 5;
				Battle.eSpeed = 2;
				Battle.eArcana = 4;
				break;
			case 2:
				Battle.eName = "Gnoll";
				Battle.ehitpoints = 10;
				Battle.emanapoints = 0;
				Battle.ePower = 7;
				Battle.eAegis = 5;
				Battle.eSpeed = 2;
				Battle.eArcana = 4;
				break;
			case 3:
				Battle.eName = "Gnoll";
				Battle.ehitpoints = 10;
				Battle.emanapoints = 0;
				Battle.ePower = 7;
				Battle.eAegis = 5;
				Battle.eSpeed = 2;
				Battle.eArcana = 4;
				break;
		}
	break;
	case 6:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Gryffin";
				Battle.ehitpoints = 18;
				Battle.emanapoints = 16;
				Battle.ePower = 13;
				Battle.eAegis = 7;
				Battle.eSpeed = 30;
				Battle.eArcana = 17;
				break;
			case 2:
				Battle.eName = "Gryffin";
				Battle.ehitpoints = 36;
				Battle.emanapoints = 32;
				Battle.ePower = 26;
				Battle.eAegis = 14;
				Battle.eSpeed = 60;
				Battle.eArcana = 34;
				break;
			case 3:
				Battle.eName = "Gryffin";
				Battle.ehitpoints = 72;
				Battle.emanapoints = 44;
				Battle.ePower = 52;
				Battle.eAegis = 28;
				Battle.eSpeed = 120;
				Battle.eArcana = 68;
				break;
		}
	break;
	case 7:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Harpy";
				Battle.ehitpoints = 14;
				Battle.emanapoints = 18;
				Battle.ePower = 14;
				Battle.eAegis = 5;
				Battle.eSpeed = 27;
				Battle.eArcana = 20;
				break;
			case 2:
				Battle.eName = "Harpy";
				Battle.ehitpoints = 28;
				Battle.emanapoints = 36;
				Battle.ePower = 28;
				Battle.eAegis = 10;
				Battle.eSpeed = 54;
				Battle.eArcana = 40;
				break;
			case 3:
				Battle.eName = "Harpy";
				Battle.ehitpoints = 56;
				Battle.emanapoints = 72;
				Battle.ePower = 56;
				Battle.eAegis = 20;
				Battle.eSpeed = 108;
				Battle.eArcana = 80;
				break;
		}
	break;
	case 8:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Werebear";
				Battle.ehitpoints = 28;
				Battle.emanapoints = 5;
				Battle.ePower = 27;
				Battle.eAegis = 18;
				Battle.eSpeed = 11;
				Battle.eArcana = 3;
				break;
			case 2:
				Battle.eName = "Werebear";
				Battle.ehitpoints = 56;
				Battle.emanapoints = 10;
				Battle.ePower = 54;
				Battle.eAegis = 36;
				Battle.eSpeed = 22;
				Battle.eArcana = 6;
				break;
			case 3:
				Battle.eName = "Werebear";
				Battle.ehitpoints = 112;
				Battle.emanapoints = 20;
				Battle.ePower = 108;
				Battle.eAegis = 72;
				Battle.eSpeed = 44;
				Battle.eArcana = 12;
				break;
		}
	break;
	case 9:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Mind Flayer";
				Battle.ehitpoints = 17;
				Battle.emanapoints = 26;
				Battle.ePower = 6;
				Battle.eAegis = 13;
				Battle.eSpeed = 19;
				Battle.eArcana = 28;
				break;
			case 2:
				Battle.eName = "Mind Flayer";
				Battle.ehitpoints = 34;
				Battle.emanapoints = 52;
				Battle.ePower = 12;
				Battle.eAegis = 26;
				Battle.eSpeed = 38;
				Battle.eArcana = 56;
				break;
			case 3:
				Battle.eName = "Mind Flayer";
				Battle.ehitpoints = 68;
				Battle.emanapoints = 104;
				Battle.ePower = 24;
				Battle.eAegis = 52;
				Battle.eSpeed = 76;
				Battle.eArcana = 112;
				break;
		}
	break;
	case 10:
		switch(Dungeon.diff) {
			case 1:
				Battle.eName = "Ogre";
				Battle.ehitpoints = 25;
				Battle.emanapoints = 14;
				Battle.ePower = 15;
				Battle.eAegis = 28;
				Battle.eSpeed = 7;
				Battle.eArcana = 12;
				break;
			case 2:
				Battle.eName = "Ogre";
				Battle.ehitpoints = 50;
				Battle.emanapoints = 28;
				Battle.ePower = 30;
				Battle.eAegis = 56;
				Battle.eSpeed = 14;
				Battle.eArcana = 24;
				break;
			case 3:
				Battle.eName = "Ogre";
				Battle.ehitpoints = 100;
				Battle.emanapoints = 46;
				Battle.ePower = 60;
				Battle.eAegis = 112;
				Battle.eSpeed = 28;
				Battle.eArcana = 48;
				break;
		}
	break;

    }
}


    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        HP = new javax.swing.JLabel();
        MP = new javax.swing.JLabel();
        Pow = new javax.swing.JLabel();
        Aeg = new javax.swing.JLabel();
        Spd = new javax.swing.JLabel();
        Arc = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        Action1 = new javax.swing.JLabel();
        Action2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        Attack = new javax.swing.JButton();
        Magic = new javax.swing.JButton();
        Item = new javax.swing.JButton();
        Retreat = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();

        jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 371, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 218, Short.MAX_VALUE)
        );

        jPanel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        HP.setText("Hit Points:");

        MP.setText("Mana Points:");

        Pow.setText("Power:");

        Aeg.setText("Aegis:");

        Spd.setText("Speed:");

        Arc.setText("Arcana:");

        jLabel2.setText("+ Player Statistics +");

        jButton1.setText("Update");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(10, 10, 10)
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(MP)
                            .add(HP)
                            .add(Pow)
                            .add(Spd)
                            .add(Aeg)
                            .add(Arc)))
                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 95, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(78, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(HP)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(MP)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Pow)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Aeg)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Spd)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Arc)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 39, Short.MAX_VALUE)
                .add(jButton1)
                .addContainerGap())
        );

        jPanel3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        Action1.setText("The Monster Appeared!");

        Action2.setText("Default");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(Action1)
                    .add(Action2))
                .addContainerGap(247, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(Action1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(Action2)
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        Attack.setText("Attack");
        Attack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AttackActionPerformed(evt);
            }
        });
        Attack.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                AttackMouseClicked(evt);
            }
        });

        Magic.setText("Magic");
        Magic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MagicActionPerformed(evt);
            }
        });

        Item.setText("Item");
        Item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ItemActionPerformed(evt);
            }
        });

        Retreat.setText("Retreat");
        Retreat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RetreatActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(Attack, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(Item, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(Magic, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
                    .add(Retreat, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Attack)
                    .add(Magic))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Item)
                    .add(Retreat))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jMenu1.setText("Menu");
        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ItemActionPerformed
// TODO add your handling code here:
        Inventory pack = new Inventory();
        pack.run();
    }//GEN-LAST:event_ItemActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
        HP.setText("HP: " + Dungeon.hitpoints + "/" +Dungeon.hitpointsmax);
        MP.setText("MP: " + Dungeon.manapoints + "/" +Dungeon.manapointsmax);
        Pow.setText("Power: " + Dungeon.power);
        Aeg.setText("Aegis: " + Dungeon.aegis);
        Spd.setText("Speed: " + Dungeon.speed);
        Arc.setText("Arcana: " + Dungeon.arcana);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void AttackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AttackActionPerformed
// TODO add your handling code here:



    }//GEN-LAST:event_AttackActionPerformed

    private void RetreatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RetreatActionPerformed
// TODO add your handling code here:
        
        setVisible(false);
    }//GEN-LAST:event_RetreatActionPerformed

    private void MagicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MagicActionPerformed
// TODO add your handling code here:

    }//GEN-LAST:event_MagicActionPerformed

    private void AttackMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_AttackMouseClicked
// TODO add your handling code here:
                int damage;
        int e;
        int v;
        int hit;
        int battleIsOver;
        Random generator = new Random();
if(Dungeon.speed >= Battle.eSpeed){
	v = generator.nextInt();
	e = v%10;
	e = e+1;
	damage =Dungeon.power- Battle.eAegis;
	hit =Dungeon.speed - Battle.eSpeed;
	if(hit <= 3){
		if(e == 1){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 7){
		if(e <= 2){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 10){
		if(e <= 3){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 13){
		if(e <= 4){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 17){
		if(e <= 5){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 20){
		if(e <= 6){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 23){
		if(e <= 7){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 27){
		if(e <= 8){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	if(hit <= 30){
		if(e <= 9){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
		
	}
	else{
		Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
		Battle.ehitpoints = Battle.ehitpoints - damage;
	}
	if(Battle.ehitpoints <= 0){
		battleIsOver = 1;
		Dungeon.wins = Dungeon.wins + 1;
	}
	
}


if(Dungeon.speed <= Battle.eSpeed){
	v = generator.nextInt();
	e = v%10;
	e = e+1;
	damage =Dungeon.power- Battle.eAegis;
	hit = Battle.eSpeed -Dungeon.speed;
	if(hit <= 3){
		if(e > 1){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 7){
		if(e > 2){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 10){
		if(e > 3){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 13){
		if(e > 4){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 17){
		if(e > 5){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 20){
		if(e > 6){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 23){
		if(e > 7){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 27){
		if(e > 8){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	if(hit <= 30){
		if(e > 9){
			Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
			Battle.ehitpoints = Battle.ehitpoints - damage;
			}
	}
	else{
		Action1.setText("You hit the "+Battle.eName+" for "+damage+" damage!");
		Battle.ehitpoints = Battle.ehitpoints - damage;
	}

	if(Battle.ehitpoints <= 0){
		battleIsOver = 1;
		Dungeon.wins += 1;
	}
        
        /*The following segment is made to be the counterattack of the monster. It first checks to see who has the greaterDungeon.speed.
* After that it randomly generates a number, modulates it down so that it can only be a number from 0-9, and then makes it from 1-10.
* Once that step is done it calculates the damage and determines the difference between the opposingDungeon.speeds. It then checks to see 
* what the random number was. It compares this to the difference inDungeon.speeds to determine if the hit was successful.*/

if(Battle.eSpeed >=Dungeon.speed){
	v = generator.nextInt();
	e = v%10;
	e = e+1;
	damage = Battle.ePower -Dungeon.aegis;
	hit = Battle.eSpeed -Dungeon.speed;
	if(hit <= 3){
		if(e == 1){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 7){
		if(e <= 2){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 10){
		if(e <= 3){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 13){
		if(e <= 4){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 17){
		if(e <= 5){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 20){
		if(e <= 6){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 23){
		if(e <= 7){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 27){
		if(e <= 8){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 30){
		if(e <= 9){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	else{
		Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
		Dungeon.hitpoints= Dungeon.hitpoints- damage;
	}

	if(Dungeon.hitpoints<= 0){
		battleIsOver = 2;
		Dungeon.losses = Dungeon.losses + 1;
	}
	
}

if(Battle.eSpeed <=Dungeon.speed){
	v = generator.nextInt();
	e = v%10;
	e = e+1;
	damage = Battle.ePower -Dungeon.aegis;
	hit =Dungeon.speed - Battle.eSpeed;
	if(hit <= 3){
		if(e == 1){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 7){
		if(e > 2){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 10){
		if(e > 3){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 13){
		if(e > 4){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 17){
		if(e > 5){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 20){
		if(e > 6){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 23){
		if(e > 7){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 27){
		if(e > 8){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	if(hit <= 30){
		if(e > 9){
			Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
			Dungeon.hitpoints= Dungeon.hitpoints- damage;
			}
	}
	else{
		Action2.setText(Battle.eName+" hit you for "+damage+" damage!");
		Dungeon.hitpoints= Dungeon.hitpoints- damage;
	}

	if(Dungeon.hitpoints<= 0){
		battleIsOver = 2;
		Dungeon.losses = Dungeon.losses + 1;
	}
	
}	
}
    }//GEN-LAST:event_AttackMouseClicked
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new BattleInterface().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Action1;
    private javax.swing.JLabel Action2;
    private javax.swing.JLabel Aeg;
    private javax.swing.JLabel Arc;
    private javax.swing.JButton Attack;
    private javax.swing.JLabel HP;
    private javax.swing.JButton Item;
    private javax.swing.JLabel MP;
    private javax.swing.JButton Magic;
    private javax.swing.JLabel Pow;
    private javax.swing.JButton Retreat;
    private javax.swing.JLabel Spd;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    // End of variables declaration//GEN-END:variables
    
}
